import req from '@/http/http'

// 社区
export const findCommunity = param => {
  let path = '/community'
  return req.get(path, param)
}

export const createCommunity = data => {
  let path = '/community/'
  return req.post(path, data)
}

export const updateCommunity = data => {
  let path = '/community/' + data.id
  return req.put(path, data)
}

export const deleteCommunity = data => {
  let path = '/community/' + data.id
  return req.delete(path, data)
}

export const findCommunityList = param => {
  let path = '/community/list'
  return req.get(path, param)
}

export const getCommunity = id => {
  let path = '/community/' + id
  return req.get(path)
}

// 楼栋
export const findBuilding = param => {
  let path = '/building'
  return req.get(path, param)
}

export const createBuilding = data => {
  let path = '/building/'
  return req.post(path, data)
}

export const updateBuilding = data => {
  let path = '/building/' + data.id
  return req.put(path, data)
}

export const deleteBuilding = data => {
  let path = '/building/' + data.id
  return req.delete(path, data)
}

export const findBuildingList = param => {
  let path = '/building/list'
  return req.get(path, param)
}

export const getBuilding = id => {
  let path = '/building/' + id
  return req.get(path)
}

// 楼栋长
export const findBuildingLeader = param => {
  let path = '/building/leader'
  return req.get(path, param)
}

// 单元
export const findUnit = param => {
  let path = '/unit'
  return req.get(path, param)
}

export const createUnit = data => {
  let path = '/unit/'
  return req.post(path, data)
}

export const updateUnit = data => {
  let path = '/unit/' + data.id
  return req.put(path, data)
}

export const findUnitList = param => {
  let path = '/unit/list'
  return req.get(path, param)
}

// 房屋
export const findHouse = param => {
  let path = '/house'
  return req.get(path, param)
}

export const createHouse = data => {
  let path = '/house/'
  return req.post(path, data)
}

export const updateHouse = data => {
  let path = '/house/' + data.id
  return req.put(path, data)
}

export const deleteHouse = data => {
  let path = '/house/' + data.id
  return req.delete(path)
}

export const getHouse = id => {
  let path = '/house/' + id + '?t=' + Math.random()
  return req.get(path)
}

export const findHouseList = param => {
  let path = '/house/list'
  return req.get(path, param)
}

// 出租房
export const findRentalHouse = param => {
  let path = '/rentalHouse'
  return req.get(path, param)
}

export const createRentalHouse = data => {
  let path = '/rentalHouse/'
  return req.post(path, data)
}

export const updateRentalHouse = data => {
  let path = '/rentalHouse/' + data.id
  return req.put(path, data)
}

export const deleteRentalHouse = data => {
  let path = '/rentalHouse/' + data.id
  return req.delete(path)
}

export const getRentalHouse = id => {
  let path = '/rentalHouse/' + id
  return req.get(path)
}

// 院落
export const findCourtyard = param => {
  let path = '/courtyard'
  return req.get(path, param)
}

export const createCourtyard = data => {
  let path = '/courtyard/'
  return req.post(path, data)
}

export const updateCourtyard = data => {
  let path = '/courtyard/' + data.id
  return req.put(path, data)
}

export const deleteCourtyard = data => {
  let path = '/courtyard/' + data.id
  return req.delete(path, data)
}

export const findCourtyardList = param => {
  let path = '/courtyard/list'
  return req.get(path, param)
}
export const getCourtyard = id => {
  let path = '/courtyard/' + id
  return req.get(path)
}
